package cn.edu.fudan.tool;

import cn.edu.fudan.type.Timeseries;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 80494 on 2017/5/18.
 * This file supply different time series segmentation method
 */
public class Segmentation {
    public static List<Timeseries> SegmentationByHand(Timeseries timeseries, Integer segmentationlength){
        List<Timeseries> segmentationSeries = new ArrayList<Timeseries>();
        Timeseries segment = new Timeseries();
        int cursor =0;
        for(cursor=0;cursor<timeseries.getValue().size();cursor++){
            segment.getValue().add(timeseries.getValue().get(cursor));
            segment.getTimestamp().add(timeseries.getTimestamp().get(cursor));
            if((cursor+1)%segmentationlength==0){
                segmentationSeries.add(segment);
                segment.clear();
            }
        }
        return segmentationSeries;
    }
}
